﻿using System;

namespace Clipping.SearchUrlConstructors
{
	class UriHelper
	{
		public static Uri ConstructAbsoluteUrl(Uri baseUri, string url)
		{
			Uri rtn = null;
			if (!string.IsNullOrEmpty(url))
			{
				if (Uri.IsWellFormedUriString(url, UriKind.Absolute))
				{
					rtn = new Uri(url);
				}
				else if (baseUri != null)
				{
					try
					{
						rtn = new Uri(baseUri, url);
					}
					catch (Exception ex) { }
				}
			}
			return rtn;
		}
	}
}
